﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sigil;

namespace SigilTests
{
	[TestClass, System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
	public partial class StoreObject
	{
		[TestMethod]
		public void Simple()
		{
			var e1 = Emit<Func<DateTime, DateTime>>.NewDynamicMethod();
			var l = e1.DeclareLocal<DateTime>();
			e1.LoadLocalAddress(l);
			e1.LoadArgument(0);
			e1.StoreObject<DateTime>();
			e1.LoadLocal(l);
			e1.Return();

			var d1 = e1.CreateDelegate();

			var now = DateTime.UtcNow;

			Assert.AreEqual(now, d1(now));
		}
	}
}